﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpBasic.ListTest
{
    public class ListTest1
    {

        public static void DoTest()
        {
            List<Info1> lst1 = new List<Info1>()
            {
                new Info1() { Id = "a1", Name = "n1" },
                new Info1() { Id = "a2", Name = "n2" },
                new Info1() { Id = "a2", Name = "n21" },
                new Info1() { Id = "a3", Name = "n3" },

            };

            List<Info1> lst2 = new List<Info1>()
            {
                new Info1() { Id = "a2", Name = "n2" },
                new Info1() { Id = "a3", Name = "n3" },

            };

            Console.WriteLine("当前list");
            //
            foreach (Info1 info1 in lst1)
            {
                Console.WriteLine(info1.Id);
            }

            //
            lst1.RemoveAll(x =>
            {
                return lst2.Exists(y => y.Id.Equals(x.Id));
            });

            Console.WriteLine("移除List2后的list");
            foreach (Info1 info1 in lst1)
            {
                Console.WriteLine(info1.Id);
            }
        }
    }

    public class Info1
    {
        public string Id { get; set; }

        public string Name { get; set; }
    }
}
